package com.CuiChangHe.studentmanager.mapper;

import com.CuiChangHe.studentmanager.dao.StudentSimpleInfoDao;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @Description :学生简单信息Mapper
 * @Author :崔昌赫
 * @Date : 2021/11/16
 */
@Mapper
@Repository
public interface StudentSimpleInfoMapper {

    @Insert("INSERT INTO studentinfo VALUES (" +
            "null," +
            "'${data.studentid}'," +
            "'${data.name}'," +
            "'${data.college}'," +
            "'${data.classes}'," +
            "'${data.status}'," +
            "'${data.birthday}'," +
            "'${data.remakes}')"
    )
    Boolean addNewStudentSimpleInfo(@Param("data") StudentSimpleInfoDao data);

    @Select("SELECT * FROM studentinfo WHERE 1=1")
    StudentSimpleInfoDao[] getAllStudentInfo();
    @Select("SELECT * FROM studentinfo WHERE id=${id}")
    StudentSimpleInfoDao[] getStudentInfoById(@Param("id")Integer id);
    @Select("SELECT * FROM studentinfo WHERE studentid='${studentid}'")
    StudentSimpleInfoDao[] getStudentInfoByStudentId(@Param("studentid")String StudentId);
    @Select("SELECT * FROM studentinfo WHERE name='${name}'")
    StudentSimpleInfoDao[] getStudentInfoByName(@Param("name")String name);
    @Select("SELECT * FROM studentinfo WHERE college='${college}'")
    StudentSimpleInfoDao[] getStudentInfoByCollege(@Param("college")String college);
    @Select("SELECT * FROM studentinfo WHERE classes='${classes}'")
    StudentSimpleInfoDao[] getStudentInfoByClass(@Param("classes")String classes);
    @Select("SELECT * FROM studentinfo WHERE status='${status}'")
    StudentSimpleInfoDao[] getStudentInfoByStatus(@Param("status")String status);
    @Select("SELECT * FROM studentinfo WHERE birthday='${birthday}'")
    StudentSimpleInfoDao[] getStudentInfoByBirthday(@Param("birthday")String birthday);
    @Update("UPDATE studentinfo SET " +
            "studentid='${data.studentid}'," +
            "name='${data.name}'," +
            "college='${data.college}'," +
            "classes='${data.classes}'," +
            "status='${data.status}'," +
            "birthday='${data.birthday}'," +
            "remakes='${data.remakes}' " +
            "WHERE studentid='${studentid}'"
    )
    Boolean updateStudentInfoByStudentId(@Param("studentid")String studentId,@Param("data") StudentSimpleInfoDao data);

    @Delete("DELETE FROM studentinfo WHERE studentid='${studentid}'")
    Boolean deleteStudentInfoByStudentId(@Param("studentid")String studentId);






}
